﻿using System;
namespace Kis.Xroad.Eu {
    
    
    [System.SerializableAttribute()]
    public class SimpleUnion : global::Xtee.Core.Schema.XsdAnySimpleType {
        
        public SimpleUnion(global::Xtee.Core.Schema.XsdString value) : 
                base((System.String)value) {
            this.Validate();
        }
        
        public SimpleUnion(global::Xtee.Core.Schema.XsdInteger value) : 
                base((System.Decimal)value) {
            this.Validate();
        }
        
        public SimpleUnion(global::Kis.Xroad.Eu.SimpleType1 value) : 
                base((System.Decimal)value) {
            this.Validate();
        }
        
        public SimpleUnion(DateTimeType0 value) : 
                base((System.DateTime)value) {
            this.Validate();
        }
        
        public SimpleUnion() : 
                base(string.Empty) {
        }
        
        public SimpleUnion(string value) : 
                base((System.IComparable)Parse(value).Value) {
            this.Validate();
        }
        
        public static bool TryParse(string value, out global::Kis.Xroad.Eu.SimpleUnion result) {
            try {
                result = new global::Kis.Xroad.Eu.SimpleUnion(value);
                return true;
            }
            catch (System.Exception ) {
                result = null;
                return false;
            }
        }
        
        public static global::Kis.Xroad.Eu.SimpleUnion Parse(string value) {
            global::Xtee.Core.Schema.XsdString _XsdString = null;
            if (global::Xtee.Core.Schema.XsdString.TryParse(value,out _XsdString)) {
                return new SimpleUnion(_XsdString);
            }
            global::Xtee.Core.Schema.XsdInteger _XsdInteger = null;
            if (global::Xtee.Core.Schema.XsdInteger.TryParse(value,out _XsdInteger)) {
                return new SimpleUnion(_XsdInteger);
            }
            global::Kis.Xroad.Eu.SimpleType1 _SimpleType1 = null;
            if (global::Kis.Xroad.Eu.SimpleType1.TryParse(value,out _SimpleType1)) {
                return new SimpleUnion(_SimpleType1);
            }
            DateTimeType0 _DateTimeType0 = null;
            if (DateTimeType0.TryParse(value,out _DateTimeType0)) {
                return new SimpleUnion(_DateTimeType0);
            }
             throw new FormatException("Cannot parse to type [global::Kis.Xroad.Eu.SimpleUnion] from string value : [" + value + "]");;
        }
        
        [System.SerializableAttribute()]
        public class DateTimeType0 : global::Xtee.Core.Schema.XsdDateTime {
            
            public DateTimeType0(System.DateTime value) : 
                    base(value) {
                this.Validate();
            }
            
            public DateTimeType0(string value) : 
                    base(value) {
                this.Validate();
            }
            
            public DateTimeType0() : 
                    base(new System.DateTime()) {
            }
            
            public static bool TryParse(string value, out DateTimeType0 result) {
                try {
                    result = new DateTimeType0(value);
                    return true;
                }
                catch (System.Exception ) {
                    result = null;
                    return false;
                }
            }
            
            public static implicit operator DateTime (DateTimeType0 value) {
                return value.Value;
            }
            
            public static implicit operator DateTimeType0 (System.DateTime value) {
                return new DateTimeType0(value);
            }
        }
    }
}
